|
ARTeam Tutorial Remote Library Loader for all the AcProtected programs |
| Information | How to use ACProtected Programs legally and a little on code injection techniques on running processes. |
| Target | DummyApp compressed with AcProtect (SUPP, a freeware patching utility for Palm apps, inside this archive). |
| Available | http://www.BPVcentral.com |
| Tools | VisualStudio 6.0, AcProtect any version. |
| Protection | MessageBox |
| level | Medium on C++ and API calls |
| Category | Patching |
| Author | &8~) Shub-Nigurrath June 2004 |
|
1. Introduction
|
|
Hi all, today's problem is quite tricky and honestly just an excuse to introduce you on how processes injection works (just a technique). The problem is quite simple: if you install AcProtect demo version it compress and obscure programs fully, but places an annoying messagebox (with an OK button) reminding that the program has been protected with an unregistered version of AcProtect. Let's call the AcProtected program ACP, so the problem is how to eliminate that annoying messagebox. Reversing AcProtect is quite difficult, and anyway there's another way to eliminate the problem, being at the same time able to legally redistribute AcProtected programs and not being accused of piracy !! The
solution is quite simple too: load into the address
space of the ACP program a DLL that intercepts
automatically the MessageBox, press Ok for you and then
go on to the program. Note that patching the Application, changing
the Export Table (change the string MessageBox to
GetMessage using an hex Editor), doesn't apply to our
target (it works of course and it's a snap to do it, but
isn't what we want). Consider this situation: I included partially an article from John Peroquin,
which describes base principles of this tecquique. |
|
2.
Limitations
|
|
An important limitation is that to make this you need to write in the target process memory, using VirtualAllocEx and similar Win2000 and above only APIs. So this method works only for Windows2000/XP. Note that there's also other solutions around, but aren't working, like Sunshine's one (http://www.sunshine2k.de/Tuts/tut_splasheasy.htm) because of AcProtect (it detects any modification to the executable's code and export table) -sic- |
|
3. Description
|
|
For the ideas here I give credit originally to Jeffrey Ricther in
Programming Applications for Microsoft Windows with his "DLL
Injection." and to John Peloquin for original post of part of this
tutorial. The primary difference between our applications is that
his works with running target processes, where this one also acts as
a target process loader. |
|
4.
The problem
|
|
There is one major problem that arises when it comes to
customizing existing applications: virtual address spaces. In 32-bit Windows
environments, each application has its own virtual address space that only its
components can see.
This means that one application cannot freely modify another without some additional work. This is the problem that is overcome with the Remote Library Loader and the use of custom DLLs. With the architecture described below, developers can work around this problem fairly easily, and accomplish their intended tasks. The architecture developed to solve the problem above can be broken down into three discrete components. These components are as follows:
We will now examine the second two components in detail. The
target application will not be discussed here because its
functionality is only pertinent to the plugin DLL developer, and
could be one of many different things. |
|
5.
The Loader & The Plugin
|
|
If an error occurs during any one of the preceding steps, a message box is presented to the user, informing them of the error. This includes if the remote LoadLibrary() call fails to load the plugin DLL. Please read the Readme.txt in the download package for specific information about loader installation/usage. The Plugin
It is important to follow this model for one main reason: Access to the entry-point function is serialized, meaning that it can be called only once at a time. Performing a lengthy operation in the DLL_PROCESS_ATTACH notification may force other threads attempting to call the entry-point function to wait, including threads within the target process (see Footnote #1). For this reason, use the model above for best performance. Once in the newly created thread, customizations can be performed, such as subclassing one of the applications windows, and so forth, and other things that you can do in the context of the target process.
1. Here it is good to remember that
newly created threads thread will attempt to call the entry-point
function with a DLL_THREAD_ATTACH notification. But it is also
important to note that even the target process primary thread may be
affected when not using this model. The reason has to do with the
functionality of CreateProcess() and LoadLibrary().
Because CreateProcess() can return before the target process
primary thread has loaded all its required DLLs, it could still be
calling LoadLibrary() even after the plugin DLL receives the
DLL_PROCESS_ATTACH notification. If a lengthy operation prevents a
return from this notification before another LoadLibrary()
call occurs, that call will attempt to send a DLL_PROCESS_ATTACH
notification. This then makes the primary thread waitg, which is
certainly not desirable. So, for these two reasons it is important
to use the recommended model for best results. |
|
6. How to make it
working
|
1. First step, place things in place:
2. Second step, running the target application |
|
7. Conclusion
|
|
Sources are included into the distribution for any customization you would do. Do anything you want of them, but please mention me if you're going to redistribuite! These are the folders contained into this archive:
A BIG thanks goes to Peroquin and all
ARTeam members (.|.)
|